/*
 * @Author: wangjun haodreams@163.com
 * @Date: 2025-05-03 11:25:21
 * @LastEditors: wangjun haodreams@163.com
 * @LastEditTime: 2025-05-04 10:52:52
 * @FilePath: \ch9329\demo\main.go
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
package main

import (
	"flag"
	"log"
	"time"

	"gitee.com/haodreams/ch9329"
)

var paddr = flag.String("addr", "com4", "端口号")
var ps = flag.Bool("shake", true, "是否定时晃动鼠标")

func shake(mk *ch9329.CH9329) {
	for {
		log.Println("晃动鼠标")
		mk.Shake()
		time.Sleep(time.Second * 60)
	}
}
func main() {
	flag.Parse()

	mk := ch9329.NewCH9329(*paddr)
	err := mk.Open()
	if err != nil {
		panic(err)
	}
	defer mk.Close()
	// time.Sleep(time.Second * 2)
	// log.Println("按下鼠标右键")
	// mk.PressMouseKey("right")
	time.Sleep(time.Second * 2)
	if *ps {
		shake(mk)
		return
	}
	time.Sleep(time.Second * 2)
	log.Println("按下鼠标左键")
	mk.PressMouseKey("left")
	log.Println("晃动鼠标")
	mk.Shake()
	mk.WriteString("\n")
	mk.WriteString("` 123456789\t0\n")
	mk.WriteString("abcdefghijglmnopqrstuvwxyz\n")
	mk.WriteString("ABCDEFGHIJKLMNOPQRSTUVWXYZ\n")
	mk.WriteString("~!@#$%^&*()_+\n")
	mk.WriteString("[]\\;',./\n")
	mk.WriteString("{}|:\"<>?\n")
	mk.WriteString("OK\n")
	// time.Sleep(time.Second * 5)
	// mk.PressKey("f1")
	// time.Sleep(time.Second * 5)
	// mk.PressKey("f2")
	// time.Sleep(time.Second * 5)
	// mk.PressKey("f3")
	// time.Sleep(time.Second * 5)
	// mk.PressKey("f10")
	// time.Sleep(time.Second * 5)
	// mk.PressKey("tab")
}
